var htmlWebpackPlugin=require("html-webpack-plugin");
var path=require("path");
var ex=require("extract-text-webpack-plugin");
const webpack=require("webpack");
module.exports={
    devtool:"source-map",
    entry:{
        login:[
            path.resolve(__dirname,"public/js/login.js"),
           
            ],
        app:[
            path.resolve(__dirname,"public/js/app.js"),
          
        ],
    },
    output:{
        path:__dirname+"/dist/",
        filename:"public/js/[name].js",
        publicPath:"/"
    },
    module:{
        loaders:[
             //单独打包css文件
            {
                test:/\.css$/,
                // use:["style-loader","css-loader"]
                use: ex.extract({
                    fallback: "style-loader",
                    use: "css-loader"
                })
            },
            //babel转码es6
             {
                //单独打包css文件
                test:/\.js$/,
                exclude:/node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['env']
                    }
                }
            },
            //图片文件打包
            {
                test:/\.(png|jpg)$/,
                loader: 'url-loader?limit=8192&name=public/images/[hash:8].[ext]',
            },
            //html文件图片打包
            {
                test:/\.html$/,
                loader:"html-loader"
            },
            { 
                test: /\.(woff|svg|eot|ttf)\??.*$/,
                loader: 'url-loader?limit=50000&name=public/font/[name].[ext]'
            },
        ]
    },
    resolve: {
        modules: [
            path.join(__dirname, "public/js"),
            "node_modules"
        ]
    },
    plugins:[
        new htmlWebpackPlugin({
            template:"views/main.html",
            filename:"views/main.html",
            chunks:["app"],
        }),
        new htmlWebpackPlugin({
            template:"index.html",
            filename:"index.html",
            chunks:["login"]
        }),
        new ex("public/css/[name].css"),
        // new webpack.HotModuleReplacementPlugin()
    ],
    // devServer:{
    //     historyApiFallback:true,
    //     hot:true,
    //     inline:true,
    //     port:8080 //端口你可以自定义
    // }
}